<template>
    <div class="container">
        <div class="indexPannelbody">
            <div class="">
                <el-button type="primary" @click="save">返回选择单位</el-button>
                <el-button type="primary" @click="logOut">退出登录</el-button>
                <h1>单位名称:&nbsp;{{companyName}}</h1>
                <h1>统一社会信用代码:&nbsp;{{creditCode}}</h1>
                <h1>组织机构代码代码:&nbsp;{{organizationCode}}</h1>
            </div>
            <div class="indexCompanyType">
                <p>单位类型：{{companyType}} &nbsp; <router-link to="/choiceFirmType" class="registrePath">修改</router-link></p>
            </div>
            <div class="formBlock">
                <p>
                    <a class="registrePath" @click="routerOut('mainTable')" v-show="form711">表711</a>&nbsp;&nbsp;
                    <a class="registrePath" @click="routerOut('fromOne')" v-show="form7111">表711-1</a>&nbsp;&nbsp;
                    <a class="registrePath" @click="routerOut('fromtwo')" v-show="form7112">表711-2</a>&nbsp;&nbsp;
                    <a class="registrePath" @click="routerOut('fromthree')" v-show="form7113">表711-3</a>&nbsp;&nbsp;
                    <a class="registrePath" @click="routerOut('fromfour')" v-show="form7114">表711-4</a>&nbsp;&nbsp;
                    <a class="registrePath" @click="routerOut('fromfive')" v-show="form7115">表711-5</a>&nbsp;&nbsp;
                    <a class="registrePath" @click="routerOut('fromsix')" v-show="form7116">表711-6</a>
                </p>
            </div>
            <!-- <div class="appointmant">
                <el-row>
                    <el-button type="success">预约上门</el-button>
                </el-row>
            </div> -->
             <div class="appointmant">
                <el-row>
                    <el-button type="success" @click="uploadTables">上传表格</el-button>
                </el-row>
            </div>
            <div class="explaination">
                <el-row>
                    <el-button type="primary">登记阶段说明</el-button>
                    <el-button class="right" type="primary">登记字段解释</el-button>
                </el-row>
            </div>
            <div >
                <el-progress class="progressBar" :percentage="progressBar" color=""></el-progress>
            </div>
            <div>
                <el-dialog 
                :visible.sync="dialogTableVisible"
                :show-close="false"
                :close-on-press-escape="false"
                :close-on-click-modal="false"
                :center="true"
                >
                <h1 style="margin-bottom:10px;">{{checkUiteStatus}}</h1>
                <span slot="footer" class="dialog-footer">
                <el-button type="primary" @click="routeCompany">重新选择单位</el-button>
                </span>
                </el-dialog>
            </div>
        </div>
    </div> 
</template>
<script>
    export default{
        data(){
            return{
                progressBar:0,
                companyName:this.$store.get("unitDetailedName"),
                creditCode:this.$store.get("socialCreditCode"),
                companyType:'',
                organizationCode:this.$store.get("organizationCode"),
                form711:false,
                form7111:false,
                form7112:false,
                form7113:false,
                form7114:false,
                form7115:false,
                form7116:false,
                dialogTableVisible:false,
                checkUiteStatus:'',
            }
        },
        mounted:function(){
            this.getState();
            this.getForms();
            this.getProgressBar();
        },
        methods:{
            //跳转并打开新的标签页
            routerOut(url){
                const { href } = this.$router.resolve({
                name: url
                })
            window.open(href, '_blank')
            },
            // 判断填表内容
            getForms(){
                let Beid = this.$store.get("type");
                let id = Beid.toString();
                switch(id){
                    case "1":
                    this.form711 = true;
                    this.companyType = '产业活动单位'
                    break;
                    case "2":
                    this.form711 = true;
                    this.form7111 = true;
                    this.form7112 = true;
                    this.form7115 = true;
                    this.form7116 = true;
                    this.companyType = '属于银行及相关金融单位'
                    break;
                    case "3":
                    this.form711 = true;
                    this.form7111 = true;
                    this.form7112 = true;
                    this.companyType = '不属于银行及相关金融单位'
                    break;
                    case "4":
                    this.form711 = true;
                    this.form7112 = true;
                    this.form7113 = true;
                    this.form7115 = true;
                    this.form7116 = true;
                    this.companyType = '属于银行及相关金融单位'
                    break;
                    case "5":
                    this.form711 = true;
                    this.form7112 = true;
                    this.form7113 = true;
                    this.companyType = '不属于银行及相关金融单位'
                    break;
                    case "6":
                    this.form711 = true;
                    this.form7112 = true;
                    this.form7114 = true;
                    this.form7115 = true;
                    this.form7116 = true;
                    this.companyType = '属于银行及相关金融单位'
                    break;
                    case "7":
                    this.form711 = true;
                    this.form7112 = true;
                    this.form7114 = true;
                    this.companyType = '不属于银行及相关金融单位'
                    break;
                }

            },
            // 获取填表进度
            getProgressBar(){
                    let self = this;
                    let baseId = this.$store.get("companyId");
                    let type = this.$store.get("type");  
                    this.$http({
                            method:'post',
                            url:'/poj/getTablesNum?baseId='+baseId+'&type='+type,
                        }).then(function(res){
                            if(res.status === 200){
                                let progressBarBedore = res.data*100;
                                self.progressBar = parseFloat(progressBarBedore.toFixed(2));
                            }else{
                                self.$message.error(res.message);
                            }
                        }).catch(function(err){
                            console.log(err)
                        })
            },
            //返回选择单位
            save(){
                this.$router.push({ path: '/choicefirm' })
            },
            //退出登录
            logOut(){
                let self = this;
                this.$http({
                            method:'get',
                            url:'/passport/logout'
                        }).then(function(res){
                            console.log(res);
                            if(res.status === 200){
                                self.$router.push({ path: '/' });
                            }else{
                                self.$message.error(res.message);
                            }
                        }).catch(function(err){
                            console.log(err)
                        })
            },
            //判断uiteStatus
            getState(){
                console.log(this.$store.get('uiteStatus'));
                let uiteStatus = this.$store.get('uiteStatus');
                if(uiteStatus==0){
                    this.checkUiteStatus = '单位验证中...';
                    this.dialogTableVisible = true;
                }else if(uiteStatus==-1){
                    this.checkUiteStatus = '单位未通过认证!';
                    this.dialogTableVisible = true;
                }
                
            },
            routeCompany(){
                this.$router.push({ path: '/choicefirm' });
            },
            //上传表格
            uploadTables(){
                this.$router.push({ path: '/uploadTables' });
            },
        }
    }
</script>